<template>
    <div>
         <el-date-picker
          v-model="searchTime"
          type="month"
          value-format="yyyy-MM"
          placeholder="选择月">
        </el-date-picker>
        <button class="sousuo" @click="search"><i class="el-icon-search"></i></button>
        <template>
            <el-table v-loading="loading" :data="dayDate" border style="width: 100%">
                <el-table-column prop="date" label="日期">
                </el-table-column>
                <el-table-column prop="raffle_cost" label="消费">
                    <template v-slot="scope">
                        ￥{{ format_money(scope.row.raffle_cost)}}
                    </template>
                </el-table-column>
                <el-table-column prop="raffle_income" label="产出">
                    <template v-slot="scope">
                        ￥{{ format_money(scope.row.raffle_income) }}
                    </template>
                </el-table-column>
                <el-table-column prop="raffle_profit" label="盈亏">
                    <template v-slot="scope">
                        ￥{{ format_money(scope.row.raffle_profit) }}
                    </template>
                </el-table-column>
                <el-table-column prop="statement_date" label="出账时间">
                </el-table-column>
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagenum"
                :page-sizes="[8, 10, 15]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </template>
    </div>
</template>

<script>
import caiwu from '../../../api/jurisdiction'
import {format_money} from "@/utils/format";
export default {
    data() {
        return {
            dayDate: [],
            loading: true,
            searchTime: null,
            pagenum: 1,
            pagesize: 8,
            total: 0
        }
    },
    created() {
        this.getMonth()
    },
    methods: {
      format_money,
        search() {
            console.log(this.searchTime)
            this.getMonth()
        },
        getMonth() {
            caiwu.yuezhangdan({ page: this.pagenum, page_size: this.pagesize, date_start: this.searchTime }).then((res) => {
                console.log('日账单', res)
                this.dayDate = res.data.data.list
                this.total = res.data.data.sum_count
                this.loading = false
            })
        },
        handleSizeChange(val) {
            this.pagesize = val
            this.getRank()
        },
        handleCurrentChange(val) {
            this.pagenum = val
            this.getRank()
        }
    },
}
</script>

<style lang="less" scoped>
.el-input {
    width: 250px;
    margin-right: 20px;
    margin-bottom: 30px;
}

.sousuo {
    margin: 6px;
    width: 50px;
    height: 40px;
    background: #009688;
    border: 0;
    color: white;
    font-size: 20px;
    vertical-align: middle;
    text-align: center;
    line-height: 40px;
    border-radius: 4px;
    cursor: pointer;
}

.el-pagination {
    text-align: center;
    margin-top: 20px;
}
</style>